﻿using ASmile.ORM.Cores;
using ASmile.ORM.Examples.DBModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASmile.ORM.Examples
{
    class Program
    {
        static void Main(string[] args)
        {
            //1. 引用nuget 包, Install-Package ASmile.ORM
            DBContext db = new DBContextDebug(EmDbType.SQLServer, "Server=.;Database=asmile-examples;Trusted_Connection=True;");

            Insert01(db);

            Console.ReadKey();

            
            
            //查询最大的 ID 
            //var maxId = db.QueryMax<Test01>(s => s.ID, s => true).ToObject<int>();



            //数据库为SqlServer
        }

        static void PrintLog(string log)
        {
            Console.WriteLine($"[{DateTime.Now:HH:mm:ss.fff}]: {log}");

        }

        #region 新增 - 生成代码的实体类增加记录

        static void Insert01(DBContext db)
        {
            var r =
            db.Insert(new Test01
            {
                ID = 1,
                Name = "张三",
                Age = 19,
                Birthday = new DateTime(1999, 9, 9),
                Salary = 8765.43m,
                Remark = ""
            });
            
            PrintLog($"新增完成，\nSqlContent:\n{r.SqlContent}");

        }

        #endregion

    }
}
